import json

from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import redirect
from django.urls import reverse
from django.conf import settings

from common import res_json_data


class AuthMiddleware(MiddlewareMixin):
    def process_request(self, request):

        pass_urls = ['/','/login/','/login/register/']
        if request.path in pass_urls:
            return

        user_info = request.session.get('user_id')

        if user_info:
            return
        return redirect(reverse('login:登录'))
